Skip to content

fix(plugin-form): the ?form overlay for a record that does not exist shows the not-found state, not an empty editable form - #29246

Merged
objectstack-fleet[bot] merged 3 commits into
mainfrom
claude/project-thread-8nyqa9
Nov 2, 2026
Merged

objectstack-fleet[bot] merged 3 commits into
mainfrom
claude/project-thread-8nyqa9

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Requested by Steedos · project thread

Fixes #29157

Clause-②: no
Metadata-protocol: none

Declarations as set by the claim (card comment 6573647843), which fixes the file surface: ModalForm.tsx, its private loadFailure.ts, their tests and a root changeset. DrawerForm, TabbedForm and WizardForm stay out by the claim.

维护者速读

  • 改了什么:控制台全局记录表单浮层(?form=ID)打开一条不存在的记录时,现在显示「Record not found」未找到状态(与记录页相同的文案),不再显示可编辑的空白「编辑」表单,也没有「更新」按钮。新建(?form=new)和编辑已存在的记录不变。
  • 为什么改:用户从已删除记录的旧链接(通知、书签、别人发来的地址)进入,会看到空白表单,填完点更新才被告知记录不存在,白填一遍;同一个 id 走 /forms 路由会直接拒绝,两处入口不一致。
  • 风险与回滚:低。只改 ModalForm 的记录读取:findOne 按契约对不存在的记录返回 null,此前被当成空记录 {} 填进表单,现在记为一次加载失败并画未找到状态。表单打开期间记录被删、后台重读得到 null 时也显示同一状态。回滚即还原本 PR。
  • 先看:ui/packages/plugin-form/src/ModalForm.tsx 的记录读取 effect(data == null 分支)与 renderContent 开头的 RecordNotFoundError 分支;ui/packages/plugin-form/src/loadFailure.ts 末尾新增的 RecordNotFoundError。
  • 两分钟验证:pnpm --dir ui exec vitest run packages/plugin-form/src/ModalForm.recordNotFound-29157.test.tsx,预期 1 个文件、4 个测试全绿。
  • 需要你做的:无,席位落地。

What changes

  • A null edit read is a failure, not an empty record. DataSource.findOne is typed T | null, and the ObjectStack adapter's readOne answers null when the server answers 404. ModalForm's record read ran setFormData(data || {}) and committed, so the console's ?form=ID overlay (AppContent mounts ModalForm with mode: 'edit' and the URL's id) drew a blank editable form with an enabled Update button for a record that does not exist. The read now fails with a new RecordNotFoundError from the package-private loadFailure.ts, through the same per-read failure run every other load failure uses, and the form is not seeded.
  • Drawn as the record not-found state. renderContent draws a RecordNotFoundError as the console's record not-found state (Empty with EmptyTitle and EmptyDescription, as RecordDetailView draws it), not as the red "Error loading form" box. The dialog's footer is already off while a load failure is set, so there is no Update or Cancel button; the dialog still closes by its X, Escape or the backdrop.
  • Copy reused, no new string. The title and description are the existing pack keys empty.recordNotFound and empty.recordNotFoundDescription, present in every locale pack. Their English values are added only to ModalForm's private createSafeTranslation fallback table, so a host with no i18n provider still reads English.
  • Also on a background re-read. A bus re-read (useRecordInvalidation) that finds the record deleted while the dialog is open shows the same state.
  • Unchanged. Create (?form=new, or no id) never reads; an edit of a record that exists draws its form as before. AppContent.tsx is not in the diff. The master-detail arm (an object with subforms) reads through MasterDetailForm and is not touched.

Tests

  • New ModalForm.recordNotFound-29157.test.tsx mounts ModalForm the way the console overlay does (object-form, formType: 'modal', mode: 'edit', an id, open: true) with the real registered fields. It pins: a null read draws "Record not found" and its description, no name input, no Update button and no "Error loading form"; a found record that a bus re-read then finds deleted switches to the same state; CONTROL a found record still draws its form and Update; CONTROL a create draws an empty form with Create and never calls findOne.

Acceptance notes

  • Live console not measured. The card measured the defect in the console at 7fa9873f. Here the chain is pinned in vitest from the findOne answer down; the adapter's 404 to null mapping is read from ObjectStackAdapter.readOne (is404Error), not re-exercised.
  • The dialog title still reads "Edit CATEGORY". The title is built by the host (AppContent), outside the claim's surface; the body says the record is not found.
  • Sibling arms (finding, not fixed here). DrawerForm, TabbedForm and WizardForm seed their forms with data || {} on a null record read in the same way. Reported to the seat for one follow-up card.

Verification

New pin · 4/4 here, 2 red against main's ModalForm

pnpm --dir ui exec vitest run --maxWorkers=2 packages/plugin-form/src/ModalForm.recordNotFound-29157.test.tsx under os-verify-lock at d68406a2: Test Files 1 passed (1), Tests 4 passed (4).

Reverse check at 64c17e66: ModalForm.tsx and loadFailure.ts restored from the base dedc3505 (the RecordNotFoundError count on disk 0), same command: Tests 2 failed, 2 passed. Both not-found cases failed with "Unable to find an element with the text: Record not found"; both CONTROLs passed. A throwaway probe on the same restored tree asserted the base behaviour directly and passed: the name input is present, empty and enabled, and the Update button is present and enabled. Restored with git restore --source=HEAD --staged --worktree; git diff HEAD empty, git status --porcelain empty, the probe file removed.

plugin-form package, overlay hosts, type check and lint
  • pnpm --dir ui exec vitest run --maxWorkers=2 packages/plugin-form/ (locked, code at 6733bc41): Test Files 218 passed (218), Tests 2411 passed, 1 skipped.
  • The 30 ui test files outside plugin-form that name ModalForm in app-shell, the console, plugin-view and plugin-designer (the AppContent.* overlay tests among them), after a turbo run build --filter='@object-ui/console^...': Test Files 30 passed (30), Tests 241 passed.
  • turbo run type-check --filter=@object-ui/plugin-form (tsc --noEmit && tsc -p tsconfig.test.json): exit 0; tsc -p tsconfig.test.json again at d68406a2: exit 0.
  • eslint on the three changed .ts/.tsx files: 0 errors; the warnings are all on lines outside this diff's hunks.
  • pnpm --dir ui run check:new-line-citations: 0 new citations.
Derived gates

node scripts/pm/dispatch-gates.mjs --commands derived 34 commands against merge base dedc35051. The 33 non-vitest gates ran in one loop starting at 6733bc41 and all exited 0, including check-sdui-manifest.mjs and its --self-test, check:nul-bytes, check:cross-package-test-inputs, check:test-source-alias, check:type-check-debt and check:query-options-erasure. pnpm --dir ui exec vitest run scripts/ at d68406a2: Test Files 169 passed, 2 skipped; Tests 4900 passed, 2 skipped. dispatch-gates --ran reconciled 34 derived, 34 run, 0 NOT-MEASURED. d68406a2 only retypes the new test file. origin/main moved 12 commits since the base, none touching ui/packages/plugin-form/, AppContent.tsx or the en locale pack.


Generated by Claude Code

… shows the not-found state

DataSource.findOne answers null for a record that does not exist, and the
dialog seeded its form with {} from that answer: a blank editable form with
an enabled Update button. A null edit read is now a RecordNotFoundError
load failure, drawn as the console's record not-found state with no form
and no footer.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QsR2jRxwsTHrYtG7dozRj9
@github-actions github-actions Bot added size/m documentation Improvements or additions to documentation tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 2, 2026
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:ui#1 · zhuangjianguo · session_01QsR2jUJ19MstFvFhjgiYTu

席位核对 · ACCEPT · 2026-11-02T10:27Z

Head-sha: d68406a25a87c855a9206357d8a8f28bc3d4c3b6

  • Shape:
    • The PR is a draft against main. The first card line is Fixes #29157, under claim 6573647843.
    • 4 files, +159 / −0: ModalForm.tsx, loadFailure.ts, one new test and a root changeset. That is the claimed surface. check-governed-merges --pr 29246: 159 changed lines, under the human-merge threshold.
    • Clause-②: no and Metadata-protocol: none start their lines in the body and the changeset, as claimed. loadFailure.ts is not on the package entry. No pack key is new: empty.recordNotFound and empty.recordNotFoundDescription exist in all ten packs, and their English values go only into ModalForm's private fallback table. The changeset is patch.
  • Read in the diff:
    • The edit read's findOne answering null (the adapter's 404) now fails the load run with RecordNotFoundError and does not seed the form.
    • renderContent draws the Empty not-found state for that error, in place of the red error box, with no form, no footer and no Update.
    • Create and a found record take the old path. A bus re-read that finds the record deleted lands in the same state.
  • Gates (check-runs on this head): 44 success, 11 skipped, 0 failed or pending. mergeable_state is clean.
  • Tests (dev):
    • The new pin passes 4 of 4. Against the base ModalForm and loadFailure, both not-found cases fail and the two controls pass. A probe confirmed base draws an empty enabled input and an enabled Update.
    • plugin-form: 218 files, 2,411 tests. 30 outside files that name ModalForm: 241 tests. Type-check exits 0. Derived gates 34 of 34.
  • NOT MEASURED: the seat ran no live session.
  • Findings: DrawerForm, TabbedForm and WizardForm: editing a record that does not exist opens a blank editable form #29247 covers the same null read in DrawerForm, TabbedForm and WizardForm. Not filed: the dialog title still reads "Edit X", because AppContent builds it.
  • Landing: ordinary queue landing, pr_ready then automerge_enable. Fixes #29157 closes the card on merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/m tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

1 participant